package com.luozhili.Swing;

import javax.swing.*;
import java.awt.*;

/**
 * 内容窗格 JScrollPane
 */
public class Demo3 extends JFrame {
    private JPanel contentPane;
    private JScrollPane scrollPane;
    private JTextArea textArea;

    public Demo3() {
        contentPane=new JPanel();
        contentPane.setLayout(new BorderLayout(0,0));
        this.setContentPane(contentPane);

        scrollPane=new JScrollPane();
        contentPane.add(scrollPane,BorderLayout.CENTER);

        //输入框 加入 滚动面板中  添加内容可见滚动窗
        textArea=new JTextArea();
        //scrollPane.add(textArea);
        scrollPane.setViewportView(textArea);

        this.setTitle("滚动面板使用");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setBounds(100, 100, 250, 200);
        this.setVisible(true);
    }

    public static void main(String[] args) {
        Demo3 demo3 = new Demo3();

    }
}
